var page=1;

function loadXMLDoc()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var json=JSON.parse(xmlhttp.responseText);

            for(let i=0;i<json.shop.length;i++){
                var img=document.createElement('img');
                img.src=json.shop[i].pic;
                var a=document.createElement('a');
                a.innerHTML=json.shop[i].text;

                var div=document.createElement('div');
                var p=document.createElement('p');
                p.innerHTML=json.shop[i].text2;
                var img1=document.createElement('img');
                img1.src=json.shop[i].pic1;
                var span=document.createElement('span');
                span.innerHTML=json.shop[i].text3;
                var span1=document.createElement('span');
                span1.innerHTML=json.shop[i].span;
                div.appendChild(p);
                div.appendChild(img1);
                div.appendChild(span);
                div.appendChild(span1);

                var b=document.createElement('b');
                b.innerHTML=json.shop[i].p;

                var s=document.createElement('s');
                s.innerHTML=json.shop[i].s;

                var li=document.createElement('li');
                li.appendChild(img);
                li.appendChild(a);
                li.appendChild(div);
                li.appendChild(b);
                li.appendChild(s);
                var list=document.querySelector("#list");
                list.appendChild(li);
            }
            console.log(list);
            //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
    };
    xmlhttp.open("GET","test"+page+".json",true);
    xmlhttp.send();
}
loadXMLDoc();

document.querySelector("#but").addEventListener('click',function(){
    if (page>=4){
        page=1;
    }else {
        page++;
    }

    document.querySelector("#list").innerHTML='';

    loadXMLDoc();
});